/**
 * Created by Administrator on 2017/12/9.
 */
window.onload = function () {
   searchEffect();
   timeBack();
    bannerEffect();
}

function  searchEffect() {
     var banner = document.querySelector('.jd_banner');
     var search = document.querySelector('.jd_search')
     window.onscroll = function () {
         var offsetHeight = banner.offsetHeight;
         var scrollTop = document.body.scrollTop;
         if (scrollTop < offsetHeight) {
             var opacity = scrollTop / offsetHeight;
             search.style.backgroundColor = "rgba(255, 35, 34, " + opacity  + ")"
         }
     }
}

function timeBack () {
     var spans = document.querySelector('.jd_time').querySelectorAll('span');
     //ʱ��
     var time1 = new Date();
     var time2 = new Date(2018, 3, 24);
     //����2017,12,25�յ����ڵ�ʱ��
     var totalTime = (time2 - time1) / 1000;
     //console.log(totalTime);
     var timerId;
     var timerId = setInterval(function() {
         totalTime--;
         if (totalTime < 0) {
             clearInterval(timerId);
             return;
         }
         var day =Math.floor(totalTime / 60 / 60 / 24);
         var hour = Math.floor(totalTime / 60 / 60 % 24);
         var minute = Math.floor(totalTime / 60 % 60);
         var second =    Math.floor(totalTime % 60);
         spans[0].innerHTML = Math.floor(day / 10);
         spans[1].innerHTML = Math.floor(day % 10);
         spans[3].innerHTML = Math.floor(hour / 10);
         spans[4].innerHTML = Math.floor(hour % 10);
         spans[6].innerHTML = Math.floor(minute / 10);
         spans[7].innerHTML = Math.floor(minute % 10);
         spans[9].innerHTML = Math.floor(second / 10);
         spans[10].innerHTML = Math.floor(second % 10);
     },1000)
}


